package Day2025_02_23;

import java.util.Scanner;



public class NowCoderDP34 {
    public static void main(String[] args) {


        Scanner scanner = new Scanner(System.in);



        int n = scanner.nextInt(), q = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) nums[i] = scanner.nextInt();
        long[] dp = new long[n + 1];
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            dp[i] = nums[i - 1] + dp[i - 1];
        }


        
        while (q != 0) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
            q--;
        }


    }

}
